//
//  BackMoneyHeader.m
//  JinChengYun
//
//  Created by 金橙云 on 2017/4/7.
//  Copyright © 2017年 金橙云. All rights reserved.
//
#define WIDTHHeader self.frame.size.width
#define D_WIDTH (self.frame.size.width)
#define D_HEIGHT (self.frame.size.height)
#define EVERY_Wi (self.frame.size.width)/5

#import "BackMoneyHeader.h"
#import "TodoHttpManager.h"
#import "MoneyFooter.h"
#import "FTPopOverMenu.h"

@implementation BackMoneyHeader
-(instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame: frame];
    if (self)
    {
        _manager = [TodoHttpManager sharedManager];
        //  均价动态表数据() 均价动态--物业类型获取
        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didTDManagerFirstJunJia:) name:TDManagerFirstJunJia object:nil];
        
        [_manager userManagerFirstJunJiaDynamic];
        //均价动态图数据
        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didTDManagerFirstJunBiao:) name:TDManagerFirstJunBiao object:nil];
        
        [_manager userManagerFirstJunJiaBiaoDynamicWithType:nil];
        
        
        //回款动态
        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didManagerFirstMoney:) name:TDManagerFirstMoney object:nil];
        [_manager userManagerFirstMoneyDynamic];
        
        
        _biaoDic = [NSMutableDictionary new];
        _tuDic = [NSMutableDictionary new];
        
        
        
        [_chatView reloadData];
        [_lineChart strokePath];

    
     
        _hengyiArr = @[@"类型",@"本月均价",@"已售均价",@"未售均价",@"综合均价"];
        
        //分段控件
        _segmented1 = [[UISegmentedControl alloc] initWithItems:@[@"按物业类型查看",@"按期数查看"]];
        _segmented1.frame = CGRectMake(10, 0, D_WIDTH-10*2, 25);
        _segmented1.selectedSegmentIndex = 0;//设置默认选择项索引
        _segmented1.tag = 11;
        _segmented1.tintColor = [UIColor orangeColor];
        [_segmented1 addTarget:self action:@selector(segmentOneBtnClick:) forControlEvents:UIControlEventValueChanged];
        [self addSubview:_segmented1];
        
        //表格
        _chatView = [[ListChartView alloc] initWithFrame:CGRectMake(0, 35, D_WIDTH, 33*4)];
        [_chatView setBorderWidth:1.0f];
        [_chatView setDelegate:self];
        [self addSubview:_chatView];
        [_chatView reloadData];
        
        
        UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(_chatView.frame)+2,D_WIDTH , 25)];
        [view setBackgroundColor:[UIColor orangeColor]];
        [self addSubview:view];
        
        UILabel *lb = [UILabel new];
        lb.frame = CGRectMake(10, 2, 150, 20);
        lb.textAlignment = NSTextAlignmentLeft;
        lb.text = @"主售房源均价动态";
        lb.textColor = [UIColor whiteColor];
        lb.font = [UIFont systemFontOfSize:14];
        [view addSubview:lb];
        
        //下来弹框
        UIButton *btn = [UIButton new];
        btn.frame = CGRectMake(D_WIDTH-130, 2, 120, 20);
        [btn setBackgroundColor:[UIColor clearColor]];
        [btn setTitle:@"高层住宅" forState:UIControlStateNormal];
        [btn setImage:[UIImage imageNamed:@"Btn_SanJiao"] forState:0];
        [btn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        btn.layer.borderWidth=1;
        btn.layer.borderColor = [UIColor whiteColor].CGColor;
        [btn setTag:1];
        btn.titleLabel.font = [UIFont systemFontOfSize:14];
        [btn addTarget:self action:@selector(xiaLaBtnClick:) forControlEvents:UIControlEventTouchUpInside];
        [view addSubview:btn];
        [btn layoutButtonWithEdgeInsetsStyle:MKButtonEdgeInsetsStyleRight imageTitleSpace:5];
        btn.layer.cornerRadius = 3;
        _selectTypeBtn =btn;
        
        //分段控件2 n年月
        _segmented2 = [[UISegmentedControl alloc] initWithItems:@[@"月",@"年"]];
        _segmented2.frame = CGRectMake(D_WIDTH-90, CGRectGetMaxY(view.frame)+5, 80, 30);
        _segmented2.selectedSegmentIndex = 0;//设置默认选择项索引
        _segmented2.tag = 12;
        _segmented2.tintColor = [UIColor orangeColor];
        [_segmented2 addTarget:self action:@selector(segmentOneBtnClick:) forControlEvents:UIControlEventValueChanged];
        [self addSubview:_segmented2];
        
        //折线图
        _lineChart = [[ZFLineChart alloc] initWithFrame:CGRectMake(-40, CGRectGetMaxY(_segmented2.frame),SCREEN_WIDTH+40, 200)];
        self.lineChart.dataSource = self;
        self.lineChart.delegate = self;
        self.lineChart.isResetAxisLineMinValue = YES;
        self.lineChart.isShowXLineSeparate = YES;
        self.lineChart.isShowYLineSeparate = YES;
        self.lineChart.linePatternType = kLinePatternTypeForCurve;
        [self addSubview:self.lineChart];
        [self.lineChart strokePath];
        
        segmentIdex  = 0;
        segmentIdex2 = 0;
        /**
         
         SDAutoLoyout 重新计算位置 自适应scrollView
         */

        
        _hengLab = [[UILabel alloc] init];
        _hengLab.text = [NSString stringWithFormat:@"  销售回款---回款动态[回款总额:%@](单位:万元)",[_huiDic objectForKey:@"huikuan_zong"]];
        NSLog(@"----%@",_huiDic );
        _hengLab.backgroundColor = [UIColor orangeColor];
        _hengLab.textColor = [UIColor whiteColor];
        _hengLab.font = [UIFont systemFontOfSize:14];
        [self addSubview:_hengLab];
        [_hengLab mas_makeConstraints:^(MASConstraintMaker *make) {
            make.size.mas_equalTo(CGSizeMake(D_WIDTH, 25));
            make.left.equalTo(self).offset(0);
            make.top.equalTo(_lineChart.mas_bottom).offset(8);
        }];
       
        
        //分段控件
        _segmented = [[UISegmentedControl alloc] initWithItems:@[@"主售房源",@"商业房源",@"配套房源"]];
        _segmented.selectedSegmentIndex = 0;//设置默认选择项索引
        _segmented.tintColor = [UIColor orangeColor];
        [_segmented addTarget:self action:@selector(segmentedBtnClick:) forControlEvents:UIControlEventValueChanged];
        [self addSubview:_segmented];
        [_segmented mas_makeConstraints:^(MASConstraintMaker *make) {
            make.size.mas_equalTo(CGSizeMake(WIDTHHeader-8*2, 25));
            make.left.equalTo(self).offset(8);
            make.top.equalTo(_hengLab.mas_bottom).offset(8);
            
        }];
        

        
        
        
        UILabel *gLine = [[UILabel alloc] init];
        gLine.backgroundColor = [UIColor grayColor];
        [self addSubview:gLine];
        [gLine mas_makeConstraints:^(MASConstraintMaker *make) {
            make.size.mas_equalTo(CGSizeMake(WIDTHHeader, 0.5f));
            make.top.equalTo(_segmented.mas_bottom).offset(8);
        }];
        
        NSInteger ge = 0;

        int AK =([UIScreen mainScreen].bounds.size.width)/4;
        
                //竖线
    
        __weak typeof(self) weakSelf = self; //对self进行weak化，否则造成循环引用无法释放controller
        
        UILabel * tempView = [[UILabel alloc]init];
        NSInteger count = 3;//设置一排view的个数
        NSInteger margin = AK;//设置相隔距离
        NSInteger height = 30;//设置view的高度
        for (int i = 0; i < 3; i ++) {
            UILabel *shuLab = [[UILabel alloc] init];
            shuLab.backgroundColor = [UIColor grayColor];
            [self addSubview:shuLab];
            if (i == 0) {
                [shuLab mas_makeConstraints:^(MASConstraintMaker *make) {
                    make.left.equalTo(weakSelf).offset(margin);
                   // make.centerY.equalTo(weakSelf);
                    make.height.mas_equalTo(height);
                    make.top.mas_equalTo(gLine.mas_bottom);
                    make.size.mas_equalTo(CGSizeMake(0.5f, 30));
                }];
            }
            else if (i == count -1){
                [shuLab mas_makeConstraints:^(MASConstraintMaker *make) {
                    make.right.equalTo(weakSelf).offset(-margin);
                    make.left.equalTo(tempView.mas_right).offset(margin);
                   // make.centerY.equalTo(tempView);
                    make.height.equalTo(tempView);
                    make.width.equalTo(tempView);
                    make.top.mas_equalTo(gLine.mas_bottom);
                    make.size.mas_equalTo(CGSizeMake(0.5f, 30));
                }];
            }
            else{
                [shuLab mas_makeConstraints:^(MASConstraintMaker *make) {
                    make.left.equalTo(tempView.mas_right).offset(margin);
                    //make.centerY.equalTo(tempView);
                    make.height.equalTo(tempView);
                    make.width.equalTo(tempView);
                    make.top.mas_equalTo(gLine.mas_bottom);
                    make.size.mas_equalTo(CGSizeMake(0.5f, 30));
                }];
            }
            tempView = shuLab;
            [view layoutIfNeeded];
        }
        


        UILabel *leiLab = [[UILabel alloc] init];
        leiLab.text = @"类别";
        leiLab.textAlignment = NSTextAlignmentCenter;
        leiLab.font = [UIFont systemFontOfSize:12];
        [self addSubview:leiLab];
        [leiLab mas_makeConstraints:^(MASConstraintMaker *make) {
            make.size.mas_equalTo(CGSizeMake(AK, 20));
            make.left.equalTo(self.mas_left).offset(ge);
            make.top.equalTo(gLine.mas_bottom).offset(5);
        }];
        
        UILabel *jinLab = [[UILabel alloc] init];
        jinLab.text = @"今日";
        jinLab.textAlignment = NSTextAlignmentCenter;
        jinLab.font = [UIFont systemFontOfSize:12];
        [self addSubview:jinLab];
        [jinLab mas_makeConstraints:^(MASConstraintMaker *make) {
            make.size.mas_equalTo(CGSizeMake(AK, 20));
            make.left.equalTo(leiLab.mas_right).offset(ge);
            make.top.equalTo(gLine.mas_bottom).offset(5);
        }];

        UILabel *yueLab = [[UILabel alloc] init];
        yueLab.text = @"本月";
        yueLab.textAlignment = NSTextAlignmentCenter;
        yueLab.font = [UIFont systemFontOfSize:12];
       // yueLab.backgroundColor = [UIColor redColor];
        [self addSubview:yueLab];
        [yueLab mas_makeConstraints:^(MASConstraintMaker *make) {
            make.size.mas_equalTo(CGSizeMake(AK, 20));
            make.left.equalTo(jinLab.mas_right).offset(ge);
            make.top.equalTo(gLine.mas_bottom).offset(5);
        }];

        UILabel *jiLab = [[UILabel alloc] init];
        jiLab.text = @"累计";
        jiLab.textAlignment = NSTextAlignmentCenter;
        jiLab.font = [UIFont systemFontOfSize:12];
        //jiLab.backgroundColor = [UIColor redColor];
        [self addSubview:jiLab];
        [jiLab mas_makeConstraints:^(MASConstraintMaker *make) {
            make.size.mas_equalTo(CGSizeMake(AK, 20));
            make.right.equalTo(self.mas_right).offset(-ge);
            make.top.equalTo(gLine.mas_bottom).offset(5);
        }];

        UILabel *graLine = [[UILabel alloc] init];
        graLine.backgroundColor = [UIColor grayColor];
        [self addSubview:graLine];
        [graLine mas_makeConstraints:^(MASConstraintMaker *make) {
            make.size.mas_equalTo(CGSizeMake(WIDTHHeader, 0.5f));
            make.top.equalTo(jinLab.mas_bottom).offset(5);
        }];
        
    }
    return self;

}

-(void)segmentedBtnClick:(UISegmentedControl *)sender
{
    self.returnTextBlock(sender.selectedSegmentIndex);
    NSLog(@"测试");
    if (sender.selectedSegmentIndex == 0) {
        NSLog(@"1");
    }else if (sender.selectedSegmentIndex == 1){
        NSLog(@"2");
    }else if (sender.selectedSegmentIndex == 2){
        NSLog(@"3");
    }else if (sender.selectedSegmentIndex == 3){
        NSLog(@"4");
    }

    
}

-(void)didTDManagerFirstJunJia:(NSNotification *)noti
{
    if (noti.object != 0)
    {
        _biaoDic = [noti.object objectForKey:@"data"];
       // NSLog(@"---------bioaDic--%@",_biaoDic);////表 包括下拉列表
        
        
        /**表
         物业类型
         */
       // NSLog(@"_biaoDic===%@",_biaoDic);
        NSMutableArray *welxzuoyiArr = [NSMutableArray new];
        NSMutableArray *welxnoZuoYiArr = [NSMutableArray new];
        NSMutableArray *welxArr = [_biaoDic objectForKey:@"wylx"];//物业类型查看表
        for (int i=0; i<welxArr.count; i++) {
            NSMutableDictionary *tmpDic = [[NSMutableDictionary alloc] initWithCapacity:0];
            tmpDic= welxArr[i];
            
            [welxzuoyiArr addObject:tmpDic[@"name"]];//按物业类型查看的纵坐标左一直
            NSArray *arr = [NSMutableArray arrayWithObjects:tmpDic[@"month_jun"],tmpDic[@"ht_jun"],tmpDic[@"unsale_jun"],tmpDic[@"zonghe_jun"], nil];
            [welxnoZuoYiArr addObject:arr];
            
            
        }
        NSLog(@"welxnoZuoYiArr==%@",welxnoZuoYiArr);
        /**表
         期数
         */
        NSMutableArray *qishuzuoyiArr = [[NSMutableArray alloc] init];
        NSMutableArray *qishunoZuoYiArr = [[NSMutableArray alloc] init];
        NSArray *qishuArr = [_biaoDic objectForKey:@"qishu"];//期数查看表
        
        NSLog(@"----期数是多少------%@--",qishuArr);
        for (int i=0; i<qishuArr.count; i++) {
            NSMutableDictionary *tmpDic = [[NSMutableDictionary alloc] initWithCapacity:0];
            tmpDic= qishuArr[i];
            
            [qishuzuoyiArr addObject:tmpDic[@"name"]];//的纵坐标左一直
            NSArray *arr = [NSMutableArray arrayWithObjects:tmpDic[@"month_jun"],tmpDic[@"ht_jun"],tmpDic[@"unsale_jun"],tmpDic[@"zonghe_jun"], nil];
            [qishunoZuoYiArr addObject:arr];
            
        }
//
        
        _zuoyishuArr = [NSArray arrayWithObjects:welxzuoyiArr,qishuzuoyiArr, nil];
        NSLog(@"_zuoyishuArr==%@",_zuoyishuArr);
        _nozuiyiArr = [NSArray arrayWithObjects:welxnoZuoYiArr,qishunoZuoYiArr, nil];
        
        //下拉列表
        
        NSMutableArray *xialaArr = _biaoDic[@"wylx_name"];
        NSMutableArray *xialaiIDArr = [NSMutableArray new];
        NSMutableArray *xialaiNameArr = [NSMutableArray new];
        
        for (int i=0; i<xialaArr.count; i++) {
            [xialaiIDArr addObject: xialaArr[i][@"id"]];
            [ xialaiNameArr addObject: xialaArr[i][@"name"]];
            
        }
        _xialiDic = @{@"id":xialaiIDArr,@"name":xialaiNameArr};
        
        
        [_chatView reloadData];
    }
}

-(void)didTDManagerFirstJunBiao:(NSNotification *)notific
{
    if (notific.object != 0)
    {
        _tuDic = [notific.object objectForKey:@"data"];
        NSLog(@"22222---------_tuDic--%@",_tuDic);//折线图 xialiDic
        
        NSDictionary *yearDic =_tuDic[@"year"];;
        NSDictionary *monthDic =_tuDic[@"month"];;
        
        /**
         年
         */
        NSMutableArray *yearConArr = [NSMutableArray new];
        NSMutableArray *yearNameArr = [NSMutableArray new];
        NSMutableArray *yearCountArr = [NSMutableArray new];
        NSMutableArray *yearMaxDataArr = [NSMutableArray new];
        NSArray *yearAllArr = [NSArray new];
        
        NSMutableArray *yearMesArr = yearDic[@"message"];
        [yearCountArr addObject:monthDic[@"count"]];//点数目
        [yearMaxDataArr addObject:monthDic[@"max_data"]];//最大值
        for (int i=0; i<yearMesArr.count; i++) {
            NSDictionary *dic = yearMesArr[i];
            [yearConArr addObject:dic[@"con"]];//每个点的数字
            [yearNameArr addObject:dic[@"name"]];////每个点下表名称
            
        }
        yearAllArr = @[yearConArr,yearNameArr,yearCountArr,yearMaxDataArr];
        
        /**
         月
         */
        NSMutableArray *monthConArr = [NSMutableArray new];
        NSMutableArray *monthNameArr = [NSMutableArray new];
        NSMutableArray *monthCountArr = [NSMutableArray new];
        NSMutableArray *monthMaxDataArr = [NSMutableArray new];
        NSArray *monthAllArr = [NSArray new];
        
        NSMutableArray *monthMesArr = monthDic[@"message"];
        [monthCountArr addObject:monthDic[@"count"]];//点数目
        [monthMaxDataArr addObject:monthDic[@"max_data"]];//最大值
        for (int i=0; i<monthMesArr.count; i++) {
            NSDictionary *dic = monthMesArr[i];
            [monthConArr addObject:dic[@"con"]];//每个点的数字
            [monthNameArr addObject:dic[@"name"]];////每个点下表名称
            
        }
        
        monthAllArr= @[monthConArr,monthNameArr,monthCountArr,monthMaxDataArr];
        
        _zhexiantuArr = @[monthAllArr,yearAllArr];
        
        [_lineChart strokePath];
        
    }
}
-(void)dealloc
{
    [[NSNotificationCenter defaultCenter] removeObserver:self name:TDManagerFirstJunJia object:nil];
    [[NSNotificationCenter defaultCenter] removeObserver:self name:TDManagerFirstJunBiao object:nil];
    
}


-(void)didManagerFirstMoney:(NSNotification *)noti
{
    if (noti.object !=0)
    {
        _huiDic = [noti.object objectForKey:@"data"];
     // NSLog(@"------------回款总的数据%@",_huiDic);
//        _dXLab.text = [_huiDic objectForKey:@"zong"];
//        _yXLab.text = [_huiDic objectForKey:@"zong_sale"];
//        _wXLab.text = [_huiDic objectForKey:@"zong_unsale"];
//       NSString *string = [_huiDic objectForKey:@"huikuan_zong"];
//        NSLog(@"------%@",string);
//        _huiLab.text = [NSString stringWithFormat:@"回款数据----[回款总额:%@](单位:元)",string];

         _hengLab.text = [NSString stringWithFormat:@"  销售回款---回款动态[回款总额:%@](单位:万元)",[_huiDic objectForKey:@"huikuan_zong"]];
        //注册通知
        [[NSNotificationCenter defaultCenter] postNotificationName:@"ValueDic" object:_huiDic];
        
        
    }
}

- (void)xiaLaBtnClick:(UIButton *)sender{
    
    // NSArray *arr = @[@"类型1",@"类型2",@"类型3",@"类型4"];
    [FTPopOverMenu showForSender:sender
                   withMenuArray:[_xialiDic objectForKey:@"name"]
                      imageArray:nil
                       doneBlock:^(NSInteger selectedIndex)//0 . . . .
     {
         [sender setTitle:[_xialiDic objectForKey:@"name"][selectedIndex] forState:UIControlStateNormal];
         /**
          筛选数据 给下面的折线图赋值
          */
         //获取到点击的是第几个item  无默认值 因为是每个item的ID
         NSString *sttt = [_xialiDic objectForKey:@"id"][selectedIndex];
         //_segmented2//代表的是年月 0 1  默认==年==0
         
         [_manager userManagerFirstJunJiaBiaoDynamicWithType:sttt];
         
         
     }
                    dismissBlock:^
     {
         
     }];
    
}
-(void)segmentOneBtnClick:(UISegmentedControl *)sender
{
    if (sender.tag==11) {//查看类型的segment
        segmentIdex = sender.selectedSegmentIndex;
        
        [_chatView reloadData];
        
        //更新表格
    }
    if (sender.tag==12){//年月segment
        segmentIdex2 = sender.selectedSegmentIndex;
        
        
        [_lineChart strokePath];
        //更新折线图
    }
    
}


#pragma mark -- 网格
/**
 表格和折线图的 横纵的值均有服务器返回取值而得 不可写死
 */
////表单行数
-(NSInteger)rowForList:(ListChartView *)list
{
    NSArray *arr = _zuoyishuArr[segmentIdex];
    NSLog(@"count==%ld",arr.count);
    // return 4;
    
    return arr.count+1;
    /**
     需要更新控件的frame
     */
}
////表单列数
-(NSInteger)columnForList:(ListChartView *)list
{
    return 5;
}
/////表单某一格字体的颜色
-(UIColor*)listChart:(ListChartView *)list textColorForRow:(NSInteger)row column:(NSInteger)column
{
    
    if (row == 0 || column == 0)
    {
        return [UIColor orangeColor];
    }
    return nil;
}
/////表单某一格的大小
-(CGSize)listChart:(ListChartView *)list itemSizeForRow:(NSInteger)row column:(NSInteger)column
{
    return CGSizeMake(EVERY_Wi, 33.0f);
}
/////表单某一格的文字
-(NSString*)listChart:(ListChartView *)list textForRow:(NSInteger)row column:(NSInteger)column
{
    if (row == 0)
    {
        for (int i=0; i<_hengyiArr.count; i++) {
            IF_T_FF(row, column, 0, i){return _hengyiArr[i];}
            
        }
    }
    else if (column == 0)
    {
        NSLog(@"%ld",_zuoyishuArr.count);
        
        for (int i = 0; i<[_zuoyishuArr[segmentIdex] count]; i++) {
            IF_T_FF(row, column, i+1, 0)
            {return _zuoyishuArr[segmentIdex][i];}
            
        }
        
    }
    /**
     这个地方处理的很不好 待处理
     */
    
    if (row==1) {
        for (int i=0; i<_hengyiArr.count-1; i++) {
            IF_T_FF(row, column, 1, i+1){return _nozuiyiArr[segmentIdex][0][i];}
            
            
        }
        
    }else if (row==2) {
        for (int i=0; i<_hengyiArr.count-1; i++) {
            IF_T_FF(row, column, 2, i+1){return _nozuiyiArr[segmentIdex][1][i];}
            
            
        }
        
    }else if (row==3) {
        for (int i=0; i<_hengyiArr.count-1; i++) {
            IF_T_FF(row, column, 3, i+1){return _nozuiyiArr[segmentIdex][2][i];}
            
            
        }
        
    }else{
        return 0;
    }
    
    return 0;
    
}
////点击触发事件
-(void)listChart:(ListChartView*)list clickForRow:(NSInteger)row column:(NSInteger)column{
    NSLog(@"点击网格row===%ld==column==%ld",(long)row,(long)column);
    
}

#pragma mark - ZFGenericChartDataSource 折线图
#pragma mark -  折线图 纵坐标
- (NSArray *)valueArrayInGenericChart:(ZFGenericChart *)chart{
    
    return (NSMutableArray *)_zhexiantuArr[segmentIdex2][0];
    
    
}
#pragma mark -  折线图 横坐标
/**
 *  组与组之间的间距(若不设置，默认为20.f)
 */
- (CGFloat)paddingForGroupsInLineChart:(ZFLineChart *)lineChart{
    return 40;
}

- (NSArray *)nameArrayInGenericChart:(ZFGenericChart *)chart{
    // NSLog(@"=1111111==%@",_zhexiantuArr[segmentIdex2][1]);
    return (NSMutableArray *)_zhexiantuArr[segmentIdex2][1];
    
}

- (NSArray *)colorArrayInGenericChart:(ZFGenericChart *)chart{
    //曲线的颜色
    return @[ZFLvColor];
   
}

- (CGFloat)axisLineMaxValueInGenericChart:(ZFGenericChart *)chart{
    return 100;
}

//背景格格
- (NSUInteger)axisLineSectionCountInGenericChart:(ZFGenericChart *)chart{
    //这里也可以根据服务器返回数据 重新布局
    return 1;
}



@end
